WordPress Blog Posts

Introduction

WordPress Blog Posts for Prestashop allows you to display your latest blog posts from your wordpress blog directly within your Prestashop
store. The module is invaluable to store owners who want to maintain a separate wordpress based blog as part of their SEO efforts and keep
the Prestashop site updated with fresh content by displaying the latest blog posts.

The module also provides you with some additional advanced features, allowing you display blog posts in different locations on your Prestashop site and posts from different blog categories.

Installation

The installation procedure is very much similar to most other Prestashop modules. No core changes are required therefore installation is straight forward. Be sure to follow the instructions below for a successful installation:

  • Upload the module folder to your store’s module folder: {root}/modules/
  • After uploading the module, in the Prestashop Back Office, head over the to the Modules section.
  • Search for the module and choose the install option
  • After a successful installation the module is ready to be used. Initially the module’s main configuration page will be displayed. We’ll take a look at how to use the module below

Configuring the module

Configuring the module

After installing the module we’ll have access to the module configuration page. Let’s head over to the module configuration page and configure the module to display the latest blog posts on our Prestashop site homepage.

The module configuration is divided into the following tabs: Blog Feed, Display Locations, Performance. Let’s take a look at each tab

Blog Feed Tab

The first thing we need to do is provide the module with the url of the blog feed. Enter a blog feed url into the blog url field. If you site is
multi-language and your blog too, then you may provide a different blog feed url for each language in your store.

Configuring the Blog Feed

In most cases the blog feed url is simply the url of your blog with /feed/ at the end of the url. You can simply enter the url of your blog and the module will automatically add the trailing /feed/ at the end.

When blog posts are displayed on our Prestashop site, when the customer clicks a post it will take them directly to the post on your wordpress blog. When this happens you have the option to either open the posts in a new tab / window or the current tab / window. This option can be configured under the dropdown labeled Open blog posts in new window/tab.

Display Locations Tab

The module lists some hooks which allow you to display your latests blog posts across different locations on your site. Furthermore each hook you can display posts from a different wordpress blog category. You can also create a custom hook to use in different places across your site.

Displaying locations for your blog posts

Let’s take a quick look at the default hooks available:

displayHome
Displays the latest blog posts on your site homepage (under the displayHome hook)

displayLeftColumn
Displays blog posts on the left hand column of your site theme.

displayRightColumn
Displays blog posts on the right hand column of your site theme.

Configuring a hook

Let’s configure the displayHome hook by clicking the edit button next to the hook name.

The options are mostly self explanatory, but let’s explore them anyway:

Enabled
Will enable or disable displaying of blog posts for the hook we are configuring.

Hook Name
The name of the hook. The name of default hooks cannot be modified, therefore this field is only useful for custom hooks you create.

Number of posts to display
Limits the number of the posts displayed by the number you enter here

Category Filter
Enter a list of category names, separated by comas and only blog posts belonging to those categories will be displayed. The category names must match the wordpress categories you have created.

Blog Feed URL
If the posts for this hook should display posts from a blog feed different to main blog feed url you set up earlier, then enter it here.

Custom Hooks

We briefly touched on the custom hook earlier and how a custom hook would allow you to manually place a shortcode in any template belonging to your theme to display blog posts in a custom location.

Simply click on the Add Custom hook button and configure the hook as described above.

After configuring the options for the custom hook, you should place the following shortcode into a template file of your choice:

{hook h="displayWBPPostsCustom" name="myhook"}

To display the blog posts for a particular hook in your CMS pages, add the following to your CMS page content where you would like the posts to appear:

[wordpressblogposts name='myhook']

The shortcodes are automatically generated for you when creating / editing custom hooks. You can simply copy and paste them in your theme templates or CMS pages.

Performance Tab

To prevent slowing down the page load times of your site, the module will cache the blog posts. By caching the blog posts, the module does
not have to connect to your blog each time and read the blog feed each time the web page is loaded. Instead it saves them to the cache and after the first load the posts are always loaded from the cache.

When you add new posts to your blog, you will need to empty the cache. You can do this by pressing the clear cached posts button under the performance tab.

You can also automate the process of clearing the blog posts on a regular basis using a Cron task. This is discussed later.

Latest Blog Posts on Product Pages

Displaying your latest blog posts on your products pages is a great way to ensure content on the product page is refreshed every so often,
which can help with SEO and also provide your customers with the opportunity to read posts related to a product.

The module allows you to display blog posts from certain blog categories in your blog … directly on the product pages. Different products can display posts from different blog categories.

To set up blog posts for your product pages, head over to Caralog > Products and edit the product you wish to display blog posts for. Under the modules tab, configure the wordpress blog posts module to see the UX for setting up things here.

You should see a list of languages, click on a list to reveal more options. It should look something like the following:

Specific blog posts for specific products

First enable the module for this product by toggling the switch labelled Display blog posts for this product.

Next, set the number of posts you wish to display on the product page.

The next steps is to select the categories from your blog from which posts should be displayed for on this product. Select one or more categories here. If your category is not listed then add it under the Add custom category section.

Once done, save the settings and the blog posts should be displayed on your product pages within the product footer.

Don’t forget to clear the blog post cache if you update these settings or any other settings in the future.

Displaying blog post images

The final step in setting up the module is to make sure wordpress includes your posts featured images in your blog feed. We do this by adding the snippet of code below to your blogs functions.php file. This is usually located in a location such as: /blog/wp-content/themes/{your_theme}/functions.php

Add the code below at the end of the functions.php file:

function add_my_rss_node() {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
        $image_url = wp_get_attachment_image_src( 
        get_post_thumbnail_id($post->ID), 'large');
        echo("<image>{$image_url[0]}</image>");
    }
}
add_action('rss2_item', 'add_my_rss_node');

Using the Cron Task

As mentioned earlier, you can automate the process of clearing the blog post cache every so often. The module includes a cron script which you can call to empty the cache.

The url to your cron script can be found in the module configuration under the performance tab.

You can add this to the Cron task manager in Prestashop or create a cron tab directly on your server or even use an external cron execution
service.

Get WordPress Blog Posts for Prestashop

Get WordPress Blog Posts on Prestashop Addons site

Get WordPress Blog Posts on Prestafusion